package com.hezhi.project.module.teacherClasses.service;

import java.util.List;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.hezhi.common.utils.StringUtils;
import com.hezhi.project.module.teacherClasses.mapper.TeacherClassesMapper;
import com.hezhi.project.module.teacherClasses.domain.TeacherClasses;
import com.hezhi.project.module.teacherClasses.service.ITeacherClassesService;
import com.hezhi.common.support.Convert;

/**
 * 教师与班级绑定 服务层实现
 * 
 * @author hezhi
 * @date 2018-08-17
 */
@Service
public class TeacherClassesServiceImpl implements ITeacherClassesService 
{
	@Autowired
	private TeacherClassesMapper teacherClassesMapper;

	/**
     * 查询教师与班级绑定信息
     * 
     * @param id 教师与班级绑定ID
     * @return 教师与班级绑定信息
     */
    @Override
	public TeacherClasses selectTeacherClassesById(Integer id)
	{
	    return teacherClassesMapper.selectTeacherClassesById(id);
	}
	
	/**
     * 查询教师与班级绑定列表
     * 
     * @param teacherClasses 教师与班级绑定信息
     * @return 教师与班级绑定集合
     */
	@Override
	public List<TeacherClasses> selectTeacherClassesList(TeacherClasses teacherClasses)
	{
	    return teacherClassesMapper.selectTeacherClassesList(teacherClasses);
	}
	
    /**
     * 新增教师与班级绑定
     * 
     * @param teacherClasses 教师与班级绑定信息
     * @return 结果
     */
	@Override
	public int insertTeacherClasses(TeacherClasses teacherClasses)
	{
	    return teacherClassesMapper.insertTeacherClasses(teacherClasses);
	}
	
	/**
     * 修改教师与班级绑定
     * 
     * @param teacherClasses 教师与班级绑定信息
     * @return 结果
     */
	@Override
	public int updateTeacherClasses(TeacherClasses teacherClasses)
	{
	    return teacherClassesMapper.updateTeacherClasses(teacherClasses);
	}
	
	/**
     * 保存教师与班级绑定
     * 
     * @param teacherClasses 教师与班级绑定信息
     * @return 结果
     */
	@Override
	public int saveTeacherClasses(TeacherClasses teacherClasses)
	{
	    Integer id = teacherClasses.getId();
		int rows = 0;
		if (StringUtils.isNotNull(id))
        {
		    rows = teacherClassesMapper.updateTeacherClasses(teacherClasses);
		}
		else
        {
		    rows = teacherClassesMapper.insertTeacherClasses(teacherClasses);
		}
		return rows;
	}
	
	/**
     * 删除教师与班级绑定对象
     * 
     * @param ids 需要删除的数据ID
     * @return 结果
     */
	@Override
	public int deleteTeacherClassesByIds(String ids)
	{
		return teacherClassesMapper.deleteTeacherClassesByIds(Convert.toIntArray(ids));
	}
	
}
